const app = getApp()
Page({
  data: {
    domainName: app.domainName,
    qiuname:'查找球队',
    qiuId:0,
    weizhi:['擅长位置', 'C（中锋）', 'PF（大前）','SF（小前）','SG（分卫）','PG（控卫）' ],
    wid:0,
    qiuhao:[],
    qhaoid:-1
  },
  onLoad(options) {
    var that = this;
    if(typeof(options.qid) != 'undefined'){
         wx.request({
          url: app.domainName + 'web/?c=getqname',
          method: 'POST',
          data: {id:options.qid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
          success: function (res) {
              that.setData({qiuname:res.data.n, qiuId: options.qid});
          }});
    }

     var _qiuhao=this.data.qiuhao;
     for(var i=0;i<100;i++){
      _qiuhao.push(i);
     }
     this.setData({qiuhao:_qiuhao });


  },
  setqiuhao(e){
    this.setData({qhaoid:  e.detail.value});
  },
  setinput(e) {
    this.setData({qiuname:  e.detail.value});
  },
  chaqiu(){
    wx.redirectTo({url: '/pages/search/index'});
  },
  goBack(){
    wx.redirectTo({url: '/pages/welcome/zu'});
  },
  dojoin(){
     var _qiuname=this.data.qiuId;
     var _weizhi=this.data.wid;
     var _qhaoid=this.data.qhaoid;
     if(0 == _qiuname){
       this.popMsg("请输入球队名称");
       return
     }
     if('' == _weizhi){
      this.popMsg("请选择球队位置");
      return
    }
    if(-1 == _qhaoid){
      this.popMsg("请选择球号");
      return
    }

    wx.request({
      url: app.domainName + 'web/?c=joinqiu',
      method: 'POST',
      data: {qname:_qiuname, qhaoid:_qhaoid,wid:_weizhi ,openid:app.globalData.openid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        wx.redirectTo({url: '/pages/welcome/viewapply'});
        return;
      }});



  },
  setweizhi(e){
    var _id=e.detail.value;
    this.setData({wid:_id});
 
  },
  popMsg(msg){
    wx.showToast({
      title: msg,
      icon: 'none',
      duration: 1500
    })
  }
 
})
